//
//  InfoDetailController.m
//  时尚男士
//
//  Created by dlios on 15-6-8.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "InfoDetailController.h"

#define HEIGHT (self.view.frame.size.height)
#define WIDTH (self.view.frame.size.width - 20)
@interface InfoDetailController ()<UIWebViewDelegate>
@property (nonatomic, retain) NSMutableArray *sourceArr;
@property (nonatomic, retain) UIScrollView *scrollView;

@property (nonatomic, retain) NSMutableArray *titleArr;
@property (nonatomic, retain) NSMutableArray *imgArr;
@property (nonatomic, retain) NSMutableArray *bodyArr;
@property (nonatomic, retain) NSMutableArray *digestArr;

@property (nonatomic, retain) UILabel *myLable;
@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UILabel *label;
@property (nonatomic, retain) UILabel *lable;
@property (nonatomic, retain) UIImageView *imageView1;
@property (nonatomic, retain) UIImageView *imageView2;
@property (nonatomic, retain) UIImageView *imageView3;
@property (nonatomic, retain) UIImageView *imageView4;

//webView
@property (nonatomic, retain) UIActivityIndicatorView *activityIndicator;

@end

@implementation InfoDetailController



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //添加加载
    self.user = [NSUserDefaults standardUserDefaults];
    self.navigationController.navigationBar.translucent = NO;
    self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    self.hud.removeFromSuperViewOnHide = YES;
    self.hud.labelText = @"加载中";
    self.hud.mode = MBProgressHUDModeIndeterminate;
    // Do any additional setup after loading the view.

    
    self.webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    //NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.Docid]];
    [self.view addSubview:_webView];
    [_webView loadRequest:request];
    [_webView release];


}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
    [view setTag:108];
    view.BackgroundColor = [UIColor blackColor];
    view.alpha = 0.5;
    [self.view addSubview:view];
    
    self.activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
    [_activityIndicator setCenter:view.center];
    [_activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
    [view addSubview:_activityIndicator];
    [_activityIndicator startAnimating];
    
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [_activityIndicator stopAnimating];
    UIView *view = (UIView *)[self.view viewWithTag:108];
    [view removeFromSuperview];
    NSLog(@"加载完成");
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [_activityIndicator stopAnimating];
    UIView *view = (UIView *)[self.view viewWithTag:108];
    [view removeFromSuperview];

}

-(void)myLayout{
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(20, 0, WIDTH ,HEIGHT - 50)];
    [self.view addSubview:self.scrollView];
    self.scrollView.backgroundColor = [UIColor lightGrayColor];
    
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 150)];
    [ self.scrollView addSubview:self.imageView];
    self.imageView.image = [UIImage imageNamed:@"reload.png"];
    
    self.scrollView.contentSize = CGSizeMake(0, 900);
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(10, 150, WIDTH, 40)];
    [ self.scrollView addSubview:self.label];
    
    self.myLable = [[UILabel alloc] initWithFrame:CGRectZero];
    [ self.scrollView addSubview:self.myLable];
    self.myLable.numberOfLines = 0;
    //self.myLable.adjustsFontSizeToFitWidth = YES;
    self.imageView1= [[UIImageView alloc] initWithFrame:CGRectZero];
    
    self.imageView1.image = [UIImage imageNamed:@"reload.png"];
    [ self.scrollView addSubview: self.imageView1];
    
    self.imageView2= [[UIImageView alloc] initWithFrame:CGRectZero];
    
    self.imageView2.image = [UIImage imageNamed:@"reload.png"];
    [ self.scrollView addSubview: self.imageView2];
    
    self.imageView3= [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH /3 * 2 + 4 , 310, WIDTH / 3 - 4 , 200)];
    
    self.imageView3.image = [UIImage imageNamed:@"reload.png"];
    [ self.scrollView addSubview: self.imageView3];
    
    
    
    self.lable = [[UILabel alloc] initWithFrame:CGRectZero];
    [ self.scrollView addSubview: self.lable];
    self.lable.numberOfLines = 0;
    self.lable.adjustsFontSizeToFitWidth = YES;
    
    
    [ self.lable release];
    
    self.imageView4 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 650, WIDTH,WIDTH / 292 * 220)];
    self.imageView4.image = [UIImage imageNamed:@"reload.png"];
    [ self.scrollView addSubview:self.imageView4];
    
    [ self.imageView1 release];
    [self.imageView release];
    [ self.label release];
    [ self.myLable release];
    [ self.scrollView release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
